package com.irdstudio.bsp.console.api.rest;

import java.util.List;

import com.irdstudio.bsp.console.service.facade.BatTaskNlsjobConfService;
import com.irdstudio.bsp.console.service.vo.BatTaskNlsjobConfVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.irdstudio.sdk.beans.core.vo.ResponseData;
import com.irdstudio.sdk.ssm.web.AbstractController;

/**
 * <p>
 * 任务运行作业配置的Controller类
 * </p>
 * @author szbd
 * @createDate 2020-06-23 09:03:35
 */
@RestController
@RequestMapping("/api")
public class BatTaskNlsjobConfController extends AbstractController {

    private static Logger logger = LoggerFactory.getLogger(BatTaskNlsjobConfController.class);

    @Autowired
    @Qualifier("taskNlsjobConfService")
    private BatTaskNlsjobConfService batTaskNlsjobConfService;
    
    /**
     * 列表数据查询
     * @param page
     * @param size
     * @return
     */
    @RequestMapping(value="/bat/task/nlsjob/confs/{taskId}", method=RequestMethod.POST)
    public @ResponseBody ResponseData<List<BatTaskNlsjobConfVO>> queryBatTaskNlsjobConfAll(@PathVariable("taskId") String taskId, BatTaskNlsjobConfVO inBatTaskNlsjobConfVo) {
        inBatTaskNlsjobConfVo.setTaskId(taskId);
        logger.info("查询任务运行作业配置的列表数据，入参：" + JSONObject.toJSONString(inBatTaskNlsjobConfVo));
        List<BatTaskNlsjobConfVO> outputVo = batTaskNlsjobConfService.queryBatTaskNlsjobConfByConditionByPage(inBatTaskNlsjobConfVo);
        return getResponseData(outputVo);
    }
    
    /**
     * 根据主键查询详情
     * @return
     */
    @RequestMapping(value="/bat/task/nlsjob/conf/{taskId}/{jobName}", method=RequestMethod.GET)
    public @ResponseBody ResponseData<BatTaskNlsjobConfVO> queryBatTaskNlsjobConfByPk(@PathVariable("taskId") String taskId, @PathVariable("jobName") String jobName) {
        BatTaskNlsjobConfVO inVo = new BatTaskNlsjobConfVO();
        inVo.setTaskId(taskId);//任务编号
        inVo.setJobName(jobName);//作业标识
        logger.info("根据主键查询任务运行作业配置的详情，入参：" + JSONObject.toJSONString(inVo));
        BatTaskNlsjobConfVO outputVo = batTaskNlsjobConfService.queryBatTaskNlsjobConfByPk(inVo);
        return getResponseData(outputVo);
    }
    
    /**
     * 根据主键删除信息
     * @param inBatTaskNlsjobConfVo
     * @return
     */
    @RequestMapping(value="/bat/task/nlsjob/conf", method=RequestMethod.DELETE)
    public @ResponseBody ResponseData<Integer> deleteBatTaskNlsjobConfByPk(@RequestBody BatTaskNlsjobConfVO inBatTaskNlsjobConfVo) {
        logger.info("根据主键删除任务运行作业配置信息，入参：" + JSONObject.toJSONString(inBatTaskNlsjobConfVo));
        int outputVo = batTaskNlsjobConfService.deleteBatTaskNlsjobConfByPk(inBatTaskNlsjobConfVo);
        logger.info("删除任务运行作业配置影响记录数：" + outputVo);
        return getResponseData(outputVo);
    }
    
    /**
     * 根据主键更新信息
     * @param inBatTaskNlsjobConfVo
     * @return
     */
    @RequestMapping(value="/bat/task/nlsjob/conf", method=RequestMethod.PUT)
    public @ResponseBody ResponseData<Integer> updateBatTaskNlsjobConfByPk(@RequestBody BatTaskNlsjobConfVO inBatTaskNlsjobConfVo) {
        logger.info("根据主键更新任务运行作业配置信息，入参：" + JSONObject.toJSONString(inBatTaskNlsjobConfVo));
        int outputVo = batTaskNlsjobConfService.updateBatTaskNlsjobConfByPk(inBatTaskNlsjobConfVo);
        logger.info("更新任务运行作业配置影响记录数：" + outputVo);
        return getResponseData(outputVo);
    }
    
    /**
     * 新增数据
     * @param inBatTaskNlsjobConfVo
     * @return
     */
    @RequestMapping(value="/bat/task/nlsjob/conf", method=RequestMethod.POST)
    public @ResponseBody ResponseData<Integer> insertBatTaskNlsjobConf(@RequestBody BatTaskNlsjobConfVO inBatTaskNlsjobConfVo) {
        logger.info("新增任务运行作业配置的记录，入参：" + JSONObject.toJSONString(inBatTaskNlsjobConfVo));
        int outputVo = batTaskNlsjobConfService.insertBatTaskNlsjobConf(inBatTaskNlsjobConfVo);
        logger.info("新增任务运行作业配置影响记录数：" + outputVo);
        return getResponseData(outputVo);
    }
    
    /**
     * 排序上移
     * @param inBatTaskNlsjobConfVo
     * @return
     */
    @RequestMapping(value="/bat/task/nlsjob/conf/moveup", method=RequestMethod.POST)
    public @ResponseBody ResponseData<Integer> moveUpBatTaskNlsjobConf(@RequestBody BatTaskNlsjobConfVO inBatTaskNlsjobConfVo) {
        logger.info("任务运行作业配置排序上移，入参：" + JSONObject.toJSONString(inBatTaskNlsjobConfVo));
        int outputVo = batTaskNlsjobConfService.moveUpBatTaskNlsjobConf(inBatTaskNlsjobConfVo);
        return getResponseData(outputVo);
    }
    
    /**
     * 排序下移
     * @param inBatTaskNlsjobConfVo
     * @return
     */
    @RequestMapping(value="/bat/task/nlsjob/conf/movedown", method=RequestMethod.POST)
    public @ResponseBody ResponseData<Integer> moveDownBatTaskNlsjobConf(@RequestBody BatTaskNlsjobConfVO inBatTaskNlsjobConfVo) {
        logger.info("任务运行作业配置排序下移，入参：" + JSONObject.toJSONString(inBatTaskNlsjobConfVo));
        int outputVo = batTaskNlsjobConfService.moveDownBatTaskNlsjobConf(inBatTaskNlsjobConfVo);
        return getResponseData(outputVo);
    }
}